import {
  faultStatus,
  workOrderCategoryType,
  workOrderDeviceType,
  workOrderUrgencyType
} from '@/types/enum'
import { TokenRequestData, TableResponseData } from '@/types/interface'
import { CascaderOption } from 'element-plus'
/** 发送消息 */
export interface SendMessageRequestData extends TokenRequestData {
  phone: string
  type: string
  content: string
}
export type SendMessageResponse = ApiResponseData<string>

/** 查询消息记录
 * @param status 0 - 未读 1 - 已读
 */
export interface QueryMessageRequestData extends TokenRequestData {
  phone: string
  type: string
}
export interface QueryMessageTableCol {
  userId: string
  messageType: string
  content: string
  messageData: string
  createdTime: string
  status: '0' | '1'
}

export type QueryMessageResponseData = TableResponseData<QueryMessageTableCol>
export type QueryMessageResponse = ApiResponseData<QueryMessageResponseData>

/**
 * 获取用户故障上报
 */
export interface queryFaultRequestData extends TokenRequestData {
  workOrderId: string
  status: string
  phone: string
  operator: string
  storeId: string
}
export interface queryFaultTableCol {
  faultId: string
  userId: number
  phone: string
  storeId: string
  storeName: string
  deviceCode: string
  longtitude: number //经度
  latitude: number //纬度
  category: string //故障分类
  imageUrls: string //图片
  faultDescription: string //描述
  status: faultStatus
  operationUser: string //操作人
  operationTime: string //操作时间
  createdTime: string //创建时间
  workOrderId: string
  message: string
}
export type queryFaultResponseData = TableResponseData<queryFaultTableCol>

export type queryFaultResponse = ApiResponseData<queryFaultResponseData>

/** 故障上报标记为已处理
 *  3已处理 4已忽略
 */
export interface renewFaultStatusRequestData extends TokenRequestData {
  faultId: string
  status: faultStatus
  remark?: string
}
export type renewFaultStatusResponse = ApiResponseData<string>
/** 查询故障上报消息记录 */
export interface queryFaultMessageRequestData extends TokenRequestData {
  faultId: string
}
export interface stepDataEntity {
  title: string
  operator: string
  content: string
  createdTime: string
  imageUrls: string
}

export type queryFaultMessageResponseData = stepDataEntity[]
export type queryFaultMessageResponse = ApiResponseData<queryWorkOrderLogResponseData>

/** 查询工单列表 */
export interface queryWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
  deviceCode: string
  deviceType: workOrderDeviceType
  dispatcher: string
  receiver: string
  type: workOrderCategoryType
  urgency: workOrderUrgencyType
  status: string
  scheduleStartTime: string
  scheduleEndTime: string
  receiveStartTime: string
  receiveEndTime: string
  remark: string
  receiverId: string
}

export interface queryWorkOrderTableCol {
  workOrderId: string
  deviceCode: string
  deviceId: number
  imageUrls: string
  category: string
  urgency: workOrderUrgencyType
  duration: string
  dispatcher: string
  createdTime: string
  receiverName: string
  receiveTime: string
  status: string
  remark: string
}
export type queryWorkOrderResponseData = TableResponseData<queryWorkOrderTableCol>

export type queryWorkOrderResponse = ApiResponseData<queryWorkOrderResponseData>
/** 提交工单 */
export interface submitWorkOrderRequestData extends TokenRequestData {
  deviceCode: string
  deviceType: workOrderDeviceType
  type: workOrderCategoryType
  category: string
  urgency: workOrderUrgencyType
  remark: string
  staffId: string
  scheduleDuration: string
  imageUrl: string
  faultId?: string
}

export type submitWorkOrderResponse = ApiResponseData<string>

/** 备注工单 */
export interface remarkWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
  remark: string
}
export type remarkWorkOrderResponse = ApiResponseData<string>

/** 查询接单人  */
export interface queryDeviceStaffRequestData extends TokenRequestData {
  deviceCode: string
}

interface staffDataType {
  id: string
  name: string
}
export interface queryDeviceStaffEntity {
  deviceCode: string
  label: string
  staffData: staffDataType[]
}
export type queryDeviceStaffResponseData = CascaderOption[]
export type queryDeviceStaffResponse = ApiResponseData<queryDeviceStaffResponseData>

/** 转派工单 */
export interface transferWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
  staffId: string
  reason: string
}

export type transferWorkOrderResponse = ApiResponseData<string>

/** 接取工单 */
export interface acceptWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
}

export type acceptWorkOrderResponse = ApiResponseData<string>

/** 取消工单 */
export interface cancelWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
}
export type cancelWorkOrderResponse = ApiResponseData<string>

/** 完成工单 */
export interface finishWorkOrderRequestData extends TokenRequestData {
  workOrderId: string
}
export type finishWorkOrderResponse = ApiResponseData<string>

/** 查询工单记录 */
export interface queryWorkOrderLogRequstData extends TokenRequestData {
  workOrderId: string
  type: 'Remark' | 'Follow'
}
export interface stepDataEntity {
  title: string
  operator: string
  content: string
  createdTime: string
  imageUrls: string
}

export type queryWorkOrderLogResponseData = stepDataEntity[]
export type queryWorkOrderLogResponse = ApiResponseData<queryWorkOrderLogResponseData>
